#include "flip_internal.h"

#define LUAF(name) int luaflip_##name(lua_State* L)

int luaflip_create_window(lua_State* L);
int luaflip_window_update(lua_State* L);
int luaflip_window_end_drawing(lua_State* L);
int luaflip_throttle_fps(lua_State* L);
int luaflip_quad(lua_State* L);
LUAF(clear);
LUAF(color);

static luaL_Reg flip[] =
{
	{"video", luaflip_create_window},
	{"update", luaflip_window_update},
	{"end_drawing", luaflip_window_end_drawing},
	{"throttle_fps", luaflip_throttle_fps},
	{"quad", luaflip_quad},
	{"clear", luaflip_clear},
	{"color", luaflip_color},
	{NULL, NULL}
};



int luaopen_flip(lua_State* L)
{
	luaflip_data* data = (luaflip_data*)lua_newuserdata(L, sizeof(luaflip_data));
	data->current_window = NULL;
	flip_draw_init(&data->draw_buffer);
	luaL_openlib(L, "flip", flip, 1);
	
	return 1;
}
